package com.qingneng.budget.service.sdk.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.qingneng.budget.dao.IProjectInfoDao;
import com.qingneng.budget.service.sdk.IProjectInfoService;
import com.qingneng.budget.vo.ProjectInfo;
import com.qingneng.budget.vo.ProjectWorkInfo;

public class ProjectInfoServiceImpl implements IProjectInfoService {
	
	private static final Logger lgger = Logger.getLogger(ProjectInfoServiceImpl.class);
	
	private IProjectInfoDao projectInfoDao = null;
	

	public IProjectInfoDao getProjectInfoDao() {
		return projectInfoDao;
	}

	public void setProjectInfoDao(IProjectInfoDao projectInfoDao) {
		this.projectInfoDao = projectInfoDao;
	}

	public List getProjectInfo(ProjectInfo projectInfo) throws Exception {
		
		return projectInfoDao.querySelective(projectInfo);
	}

	public Integer getProjectInfoTotalCount(ProjectInfo projectInfo) throws Exception {
		return projectInfoDao.querySelectvieTotalCount(projectInfo);
	}

	public List getProjectWorkInfo(int project_id) throws Exception {
		Map parameterMap = new HashMap();
		parameterMap.put("projectInfo_id",project_id);
		return projectInfoDao.getChildDetail(parameterMap);
	}

	public int addProjectInfo(ProjectInfo bean) throws Exception {
		return projectInfoDao.insert(bean);
	}

	public void addProjectWorkChildInfo(ProjectWorkInfo bean) throws Exception {
		projectInfoDao.insertChild(bean);
	}

	public void destroyProjectWorkChildInfo(ProjectWorkInfo bean)
			throws Exception {
		projectInfoDao.deleteChild(bean);
	}

	public void destroyProjectInfo(ProjectInfo bean) throws Exception {
		lgger.info("projectinfo'id is :"+ bean.getId());
		projectInfoDao.delete(bean);
		ProjectWorkInfo workInfoBean = new ProjectWorkInfo();
		workInfoBean.setProjectinfo_id(bean.getId());
		
		lgger.info("projectWorkInfo'projectInfo_id is :"+ workInfoBean.getProjectinfo_id());
		projectInfoDao.deleteChildByParentId(workInfoBean);
		
	}

	public void modifyProjectWorkChildInfo(ProjectWorkInfo bean)
			throws Exception {
		projectInfoDao.updateChild(bean);	
	}

	public void modifyProjectInfo(ProjectInfo bean) throws Exception {
		projectInfoDao.update(bean);
		
	}


}
